package com.waypolice.common.pdfUtil;

import com.waypolice.common.utils.DateTimeUtil;

import java.util.Date;

/**
 * @author wangrang
 * @create 2018-04-19 15:34
 * @file name   JudgmentObjectAttr
 * @desc 判断Object中数据类型
 **/
public class JudgmentObjectAttr {

    /**
     * 判断Object是那种类型，并返回该类型的String
     * @param obj
     * @return
     */
    public static String JudementAttr(Object obj){
        String str= null;
        Object param = obj;
        if (param instanceof Integer) {
            int value = ((Integer) param).intValue();
            str=String.valueOf(value);
        } else if (param instanceof String) {
            str = (String) param;
        } else if (param instanceof Double) {
            double d = ((Double) param).doubleValue();
            str=String.valueOf(d);
        } else if (param instanceof Float) {
            float f = ((Float) param).floatValue();
            str=String.valueOf(f);
        } else if (param instanceof Long) {
            long l = ((Long) param).longValue();
            str=String.valueOf(l);
        } else if (param instanceof Boolean) {
            boolean b = ((Boolean) param).booleanValue();
            str=String.valueOf(b);
        } else if (param instanceof Date) {
            Date date = (Date) param;
            str = DateTimeUtil.dateToStrLong(date);
        }

        return str;
    }
}
